<%@ page language="java" import="java.util.*, model.*" pageEncoding="ISO-8859-1"%>

<%@page import="bean.PollUser"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
    String title = "Home"; 
    ArrayList pa = new ArrayList();
    ArrayList pc = new ArrayList();
    ArrayList pm = new ArrayList();
    ArrayList pu = new ArrayList();
    ArrayList sa = new ArrayList();
    java.util.Date Date1 = new java.util.Date();
    pa = PCmasterImpl.showPollAdmin();
    pc = PCmasterImpl.showPollCreator();
    pm = PCmasterImpl.showPollMaster();
    pu = PCmasterImpl.showPollUser();
    sa = PCmasterImpl.showSysAdmin();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head> 
<title>Report</title>
    <style type="text/css">
<!--
.STYLE1 {font-family: "Times New Roman", Times, serif}
.STYLE2 {
    font-size: 14px;
    font-family: "Courier New", Courier, monospace;
}
.STYLE4 {font-size: 12px}
.STYLE6 {font-size: 10px}
.STYLE7 {
    font-size: 18px;
    font-weight: bold;
}
.STYLE8 {
    font-size: 16px;
    font-family: "Courier New", Courier, monospace;
}
.STYLE10 {font-size: 14px; font-family: "Courier New", Courier, monospace; }
.STYLE11 {font-family: "Courier New", Courier, monospace}
.STYLE12 {font-size: 12px; font-family: "Courier New", Courier, monospace; }
-->
    </style>
</head>
<body>
    <div class='clearboth'>
      <div align="center" class="STYLE7">
        <p align="left" class="STYLE8 STYLE11">System Utilisation Report</p>
        <p align="left" class="STYLE12">Date:&nbsp; <%= new Date() %></p>
      </div>
    </div>
<div class="STYLE11" id="SysAdmin">
            <h2 class="STYLE2">System Administrator</h2>
            <table border="1" width="76%" cellpadding="0" cellspacing="0" color="red" bordercolor="#FFFFFF">
              <thead>
                <tr id="row3" align="left">
                  <th width="16%" class="STYLE10"><span class="STYLE4 STYLE4">Username</span></th>
                  <th width="14%" class="STYLE10"><span class="STYLE4 STYLE4">Email</span></th>
                  <th width="17%" class="STYLE10"><span class="STYLE4 STYLE4">First name</span></th>
                  <th width="16%" class="STYLE10"><span class="STYLE4 STYLE4">Last name</span></th>
                  <th width="37%" class="STYLE10"><span class="STYLE4 STYLE4">Create Date</span></th>
                </tr>
              </thead>
              <tbody>
                <%
                                    for (int i = 0; i < sa.size(); i++) {                                  
                                        PollUser pb = (PollUser)sa.get(i);                                      
                                %>
                <tr id= <%=pb.getUsername()%>3 <%                                  
%>>
                  <td class="STYLE10"><span class="STYLE4"><%=pb.getUsername()%></span></td>
                  <td class="STYLE10"><span class="STYLE4"><%=pb.getEmail()%></span></td>
                  <td class="STYLE10"><span class="STYLE4"><%=pb.getFirstname()%></span></td>
                  <td class="STYLE10"><span class="STYLE4"><%=pb.getLastname()%></span></td>
                  <td class="STYLE10"><span class="STYLE4"><%=pb.getCreateDate()%></span></td>
                </tr>
                <%
                    }                      
                %>
              </tbody>
            </table>
</div >
    <span class="STYLE11"><br>
            </span>
    <div class="STYLE11" id="PollAdmin">
            <h2 class="STYLE2">Poll Administrator</h2>
             <table border="1" Width="100%" cellpadding="0" cellspacing="0" color="red" bordercolor="#FFFFFF">
                <thead>
                <tr id="row1" align="left">
                <th class="STYLE4"><span class="STYLE4 STYLE4">Username</span></th>
                <th class="STYLE4"><span class="STYLE4 STYLE4">Email</span></th>
                <th class="STYLE4"><span class="STYLE4 STYLE4">First name</span></th>
                <th class="STYLE4"><span class="STYLE4 STYLE4">Last name</span></th>
                <th class="STYLE4"><span class="STYLE4 STYLE4">Create Date</span></th>
                <th class="STYLE4"><span class="STYLE4 STYLE4">Expire Date</span></th>
                <th class="STYLE4"><span class="STYLE4 STYLE4">&nbsp</span></th>
                </tr>
                </thead>              
                <tbody>              
                <%
                                    for (int i = 0; i < pa.size(); i++) {                                  
                                        PollUser pb = (PollUser) pa.get(i);                                      
                                %>              
                <tr id= <%=pb.getUsername()%> <%                                  
   Date dd = pb.getExpireDate();
   String t = dd.toString();
   long n1=new java.text.SimpleDateFormat("yyyy-MM-dd").parse(t).getTime();
   long n2=java.util.Calendar.getInstance().getTimeInMillis();

   long n3=n1-n2;
   System.out.println("n1"+n1);
   System.out.println("n2"+n2);
   System.out.println("n3"+n3);
   long n4=n3/10;
   long n5=259200000;
%>>      
                <td class="STYLE4"><span class="STYLE4"><%=pb.getUsername()%></span></td>
                <td class="STYLE4"><span class="STYLE4"><%=pb.getEmail()%></span></td>  
                <td class="STYLE4"><%=pb.getFirstname()%></td>
                <td class="STYLE4"><span class="STYLE4"><%=pb.getLastname()%></span></td>
                <td class="STYLE4"><%=pb.getCreateDate()%></td>
                <td class="STYLE4"><%=pb.getExpireDate()%></td>
                <td class="STYLE4"><%if(n4<n5) out.print("*");%></td>                  
                </tr>              
                <%
                    }                      
                %>
                </tbody>
            </table>       
        </div >
        <span class="STYLE11"><br>
        </span>
        <div class="STYLE11" id="PollCreator">
        <h2 class="STYLE2">Poll Creator</h2>
           <table border="1" Width="100%" cellpadding="0" cellspacing="0" color="red" bordercolor="#FFFFFF">
              <thead>
                <tr id="row1" align="left">
                <th class="STYLE4"><span class="STYLE4">Username</span></th>
                <th class="STYLE4"><span class="STYLE4">Email</span></th>
                <th class="STYLE4"><span class="STYLE4">First name</span></th>
                <th class="STYLE4"><span class="STYLE4">Last name</span></th>
                <th class="STYLE4"><span class="STYLE4">Create Date</span></th>
                </tr>
              </thead>                              
              <tbody>              
                <%
                                    for (int i = 0; i < pc.size(); i++) {          
                                        PollUser pb = (PollUser) pc.get(i);
                                %>              
                <tr id= <%=pb.getUsername()%>>      
                <td class="STYLE4"><span class="STYLE4"><%=pb.getUsername()%></span></td>
                <td class="STYLE4"><span class="STYLE4"><%=pb.getEmail()%></span></td>  
                <td class="STYLE4"><span class="STYLE4"><%=pb.getFirstname()%></span></td>
                <td class="STYLE4"><span class="STYLE4"><%=pb.getLastname()%></span></td>
                <td class="STYLE4"><span class="STYLE4"><%=pb.getCreateDate()%></span></td>
                </tr>
                <%
                    }
                %>
              </tbody>
          </table>       
      </div >      
        <span class="STYLE11"><br>
        </span>
        <div class="STYLE11" id="PollCreator">
        <h2 class="STYLE2">Poll Master</h2>
        <table border="1" width="100%" cellpadding="0" cellspacing="0" color="red" bordercolor="#FFFFFF">
          <thead>
            <tr id="row2" align="left">
              <th class="STYLE2"><span class="STYLE4">Username</span></th>
              <th class="STYLE2"><span class="STYLE4">Email</span></th>
              <th class="STYLE2"><span class="STYLE4">First name</span></th>
              <th class="STYLE2"><span class="STYLE4">Last name</span></th>
              <th class="STYLE2"><span class="STYLE4">Create Date</span></th>
            </tr>
          </thead>
          <tbody>
            <%
                                    for (int i = 0; i < pm.size(); i++) {                                  
                                        PollUser pb = (PollUser) pm.get(i);
                                %>
            <tr id= <%=pb.getUsername()%>2>
              <td class="STYLE2"><span class="STYLE4"><%=pb.getUsername()%></span></td>
              <td class="STYLE2"><span class="STYLE4"><%=pb.getEmail()%></span></td>
              <td class="STYLE2"><span class="STYLE4"><%=pb.getFirstname()%></span></td>
              <td class="STYLE2"><span class="STYLE4"><%=pb.getLastname()%></span></td>
              <td class="STYLE2"><span class="STYLE4"><%=pb.getCreateDate()%></span></td>
            </tr>
            <%
                    }                      
                %>
          </tbody>
        </table>
</div >
        <span class="STYLE11"><br>
        </span>
        <div class="STYLE1" id="PollCreator">
        <h2 class="STYLE10">Poll User</h2>
             <table border="1" Width="100%" cellpadding="0" cellspacing="0" color="red" bordercolor="#FFFFFF">
                <thead>
                <tr id="row1" align="left">
                <th class="STYLE12"><span class="STYLE4">Username</span></th>
                <th class="STYLE12"><span class="STYLE4">Email</span></th>
                <th class="STYLE12"><span class="STYLE4">First name</span></th>
                <th class="STYLE12"><span class="STYLE4">Last name</span></th>
                <th class="STYLE12"><span class="STYLE4">Create Date</span></th>
                </tr>
                </thead>                              
                <tbody>              
                <%
                                    for (int i = 0; i < pu.size(); i++) {                                  
                                        PollUser pb = (PollUser) pu.get(i);
                                %>              
                <tr id= <%=pb.getUsername()%>>      
                <td class="STYLE12"><span class="STYLE4"><%=pb.getUsername()%></span></td>
                <td class="STYLE12"><span class="STYLE4"><%=pb.getEmail()%></span></td>  
                <td class="STYLE12"><span class="STYLE4"><%=pb.getFirstname()%></span></td>
                <td class="STYLE12"><span class="STYLE4"><%=pb.getLastname()%></span></td>
                <td class="STYLE12"><span class="STYLE4"><%=pb.getCreateDate()%></span></td>
                </tr>              
                <%
                    }                      
                %>
                </tbody>
            </table>   
            <span class="STYLE6"><br>
            <span class="STYLE4">Poll administrator account expires within 30 days marked with star(*).</span></span></div >          
</body>
</html>